package com.health.pay.tencent.business;

import org.slf4j.LoggerFactory;

import com.health.pay.tencent.common.Log;
import com.health.pay.tencent.common.XMLParser;
import com.health.pay.tencent.protocol.closeorder.CloseOrderReqData;
import com.health.pay.tencent.protocol.closeorder.CloseOrderResData;
import com.health.pay.tencent.service.CloseOrderService;

public class CloseOrderBusiness {

	private static Log log = new Log(LoggerFactory
			.getLogger(CloseOrderBusiness.class));
	private CloseOrderService closeOrderService;

	public CloseOrderBusiness() throws IllegalAccessException,
			ClassNotFoundException, InstantiationException {
		closeOrderService = new CloseOrderService();
	}
	
	public CloseOrderResData run(CloseOrderReqData closeOrderReqData)throws Exception {
		
		String closeOrderServiceResponseString;
		long costTimeStart = System.currentTimeMillis();
		String objXmlString=XMLParser.map2XmlString(closeOrderReqData.toMap());
		closeOrderServiceResponseString = closeOrderService
				.request(objXmlString);

		long costTimeEnd = System.currentTimeMillis();
		long totalTimeCost = costTimeEnd - costTimeStart;
		CloseOrderResData closeOrderResData=(CloseOrderResData) XMLParser.getObjectFromXML(closeOrderServiceResponseString,CloseOrderResData.class);
		return closeOrderResData;
	}
}
